from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Permission
from apps.meiduo_admin.utils import PageNum
from ..serializers.permission import PermissionListSerializer, ContentTypeSerializer
from django.contrib.contenttypes.models import ContentType
from rest_framework.response import Response

class PermissionListView(ModelViewSet):

    queryset = Permission.objects.all()
    serializer_class = PermissionListSerializer
    pagination_class = PageNum


class ContentTypeView(APIView):

    def get(self, request):
        # 获取对象
        instances = ContentType.objects.all()
        serializer = ContentTypeSerializer(instance=instances, many=True)
        return Response(serializer.data)